﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Events - Event Handling</title>
    <script src="script/jquery-1.3.2.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("button:first").click(function() {
                update($("span:first"));
            });
            $("button:last").click(function() {
                $("button:first").trigger('click');

                update($("span:last"));
            });
        });
        
        function update(j) {
            var n = parseInt(j.text(), 0);
            j.text(n + 1);
        } 
    </script>
</head>
<body>
    <button>Button #1</button> 

    <button>Button #2</button> 
    <div><span>0</span> button #1 clicks.</div> 
    <div><span>0</span> button #2 clicks.</div>
</body>
</html>
